var fs = require("fs");

/*
read
 */
// var path = __dirname + "\\Test.js";
// console.log(path);
//
// var data = "";
// var readStream = fs.createReadStream(path);
// readStream.setEncoding('UTF8');
// readStream.on("data", function (chunk) {
//     data += chunk;
// });
// readStream.on("end", function () {
//     console.log(data);
// });
// readStream.on("error", function (err) {
//     console.log(err.stack);
// });

/*
write
 */
// var writeStream = fs.createWriteStream(__dirname + "\\Test.js");
// writeStream.write("测试写入的数据","UTF8");
// writeStream.end();
// writeStream.on("finish", function () {
//     console.log("finish");
// });
// writeStream.on("error", function (err) {
//     console.log(err.stack);
// });

/*
流复制
 */
// var writeStream = fs.createWriteStream(__dirname + "\\Test.js");
// var readStream = fs.createReadStream(__dirname + "\\Stream.js");
// readStream.pipe(writeStream);

/*
链式流
 */
// var zlib = require("zlib");
// fs.createReadStream(__dirname+"\\Stream.js")
//     .pipe(zlib.createGzip())
//     .pipe(fs.createWriteStream(__dirname + "\\Test.gz"));


